﻿using Xamarin.Forms;

namespace Games.Klotski
{
    class GameCell : Image
    {
        public static readonly ImageSource ImgTarget = ImageSource.FromFile("bbh_target.png");
        public static readonly ImageSource ImgBlock0 = ImageSource.FromFile("bbh_block0.png");
        public static readonly ImageSource ImgBlock1 = ImageSource.FromFile("bbh_block1.png");
        public static readonly ImageSource ImgBlock2 = ImageSource.FromFile("bbh_block2.png");
        public static readonly ImageSource ImgBlock3 = ImageSource.FromFile("bbh_block3.png");
        public GameCell(Piece piece)
        {
            this.Piece = piece;
            if(piece.Id == 0)
            {
                this.Source = ImgTarget;
            }
            else if(piece.Id > 0)
            {
                if(piece.H == 1)
                {
                    this.Source = piece.W == 2 ? ImgBlock0 : ImgBlock1;
                }
                else
                {
                    this.Source = piece.H == 2 ? ImgBlock2 : ImgBlock3;
                }
            }
        }
        public Piece Piece { get; }
    }
}
